package com.huawei.appgallery.forum.user.usercenter.widget;

import android.content.Context;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.huawei.appgallery.forum.base.card.bean.CommentReference;
import com.huawei.appgallery.forum.base.card.bean.User;
import com.huawei.appgallery.forum.cards.widget.PostTitleTextView;
import o.azb;
import o.bse;
import o.cbb.b;
import o.cbb.d;
import o.cbb.e;
import o.cbb.j;
import o.cbu;
import o.ccc;
import o.cil;
import o.cim.a;
import o.dof;

public class CommentReferenceView extends RelativeLayout {
    private CommentReference ʽ;
    private TextView ˊ;
    private Context ˋ;
    private PostTitleTextView ˎ;
    private LinearLayout ˏ;
    private CommentReferenceUserView ॱ;
    private String ॱॱ;
    private String ᐝ;

    public CommentReferenceView(Context context) {
        super(context);
        ˏ(context);
    }

    public CommentReferenceView(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        ˏ(context);
    }

    public CommentReferenceView(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        ˏ(context);
    }

    public void setDomain(String str) {
        this.ॱॱ = str;
        this.ॱ.setDomainId(str);
    }

    private void ˏ(Context context) {
        this.ˋ = context;
        View inflate = LayoutInflater.from(context).inflate(d.ʽ, this);
        this.ॱ = (CommentReferenceUserView) inflate.findViewById(b.ॱˊ);
        this.ˎ = (PostTitleTextView) inflate.findViewById(b.ᐝ);
        this.ˏ = (LinearLayout) inflate.findViewById(b.ॱˎ);
        this.ˊ = (TextView) inflate.findViewById(b.ʻॱ);
        inflate.setOnClickListener(new 5(this));
    }

    public void setReference(CommentReference commentReference) {
        this.ʽ = commentReference;
        if (commentReference == null) {
            ˊ(true);
            this.ˊ.setText(bse.ˏ.ॱ(400012).ˎ());
            this.ॱ.setUser(null);
            this.ॱ.setSectionName("");
            this.ᐝ = null;
            return;
        }
        User ॱ = commentReference.ॱ();
        if (ॱ != null) {
            this.ॱ.setUser(ॱ);
        }
        this.ॱ.setSectionName(commentReference.ॱॱ());
        this.ᐝ = commentReference.ʽ();
        ˏ(commentReference);
    }

    private void ˏ(CommentReference commentReference) {
        if (commentReference.ˊ() == 0) {
            ˊ(false);
            if (dof.ʽ(commentReference.ˋ())) {
                String ˎ = commentReference.ˎ();
                if (ˎ == null) {
                    this.ˎ.setVisibility(8);
                    return;
                } else if (commentReference.ॱ().ॱ() == null) {
                    ˊ(true);
                    this.ˊ.setText(bse.ˏ.ॱ(400012).ˎ());
                    return;
                } else if (!"".equals(ˎ)) {
                    ˊ(false);
                    this.ˎ.setText(cbu.ˋ(ˎ));
                    return;
                } else if (commentReference.ʼ()) {
                    ˊ(false);
                    this.ˎ.setText(j.ʽ);
                    return;
                } else {
                    return;
                }
            }
            this.ˎ.setTextViewWidth((((azb.ॱ(this.ˋ) - this.ˋ.getResources().getDimensionPixelSize(e.ˋॱ)) - this.ˋ.getResources().getDimensionPixelSize(e.ˎ)) - azb.ᐝ(this.ˋ)) - azb.ˏ(this.ˋ));
            this.ˎ.setData(commentReference.ˋ(), commentReference.ˏ());
            ˊ(false);
            return;
        }
        ˋ(commentReference);
    }

    private void ˊ(boolean z) {
        if (z) {
            this.ˏ.setVisibility(0);
            this.ˎ.setVisibility(8);
            return;
        }
        this.ˏ.setVisibility(8);
        this.ˎ.setVisibility(0);
    }

    private void ˋ(CommentReference commentReference) {
        ˊ(true);
        if (commentReference.ˊ() == 2) {
            this.ˊ.setText(j.ॱ);
        } else if (commentReference.ˊ() == 3) {
            this.ˊ.setText(j.ˋॱ);
        } else if (commentReference.ˊ() == 4) {
            this.ˊ.setText(j.ॱˊ);
        } else if (commentReference.ˊ() == 1) {
            this.ˊ.setText(bse.ˏ.ॱ(400006).ˎ());
        } else {
            this.ˏ.setVisibility(8);
        }
    }

    public void ˋ() {
        cil.ˋ(this.ˋ, new a().ˊ(this.ᐝ).ˋ());
        if (!TextUtils.isEmpty(this.ᐝ)) {
            ccc.ˋ().ˏ(this.ˋ, this.ᐝ, 0, this.ॱॱ);
        } else if (this.ʽ == null) {
            ccc.ˋ().ˏ(this.ˋ, this.ᐝ, 400012, this.ॱॱ);
        } else if (this.ʽ.ॱ().ॱ() == null) {
            ccc.ˋ().ˏ(this.ˋ, this.ᐝ, 400012, this.ॱॱ);
        }
    }
}
